//
//  WJQNearbyCollectionViewCell.m
//  TripTogether
//
//  Created by dllo on 15/12/23.
//  Copyright © 2015年 王军岐. All rights reserved.
//

#import "WJQNearbyCollectionViewCell.h"
#import "WJQNearbyModel.h"
#import "WJQNearbyTableViewCell.h"

@interface WJQNearbyCollectionViewCell () <UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, retain) UITableView *tableView;

@end


@implementation WJQNearbyCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews {
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 10, SCREEN_WIDTH, self.frame.size.height) style:UITableViewStylePlain];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.backgroundColor = [UIColor clearColor];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.tableView registerClass:[WJQNearbyTableViewCell class] forCellReuseIdentifier:@"otherCell"];
    self.tableView.rowHeight = 140;
    [self.contentView addSubview:self.tableView];

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return self.otherArray.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    WJQNearbyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"otherCell"];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;

    
    WJQNearbyModel *mod = _otherArray[indexPath.row];
    
    cell.other = mod;
    
    cell.backgroundColor = [UIColor clearColor];
    
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    //    [self.delegate pushDetailViewController:[[self.otherArray objectAtIndex:indexPath.row] Id]];
}

- (void)setOtherArray:(NSMutableArray *)otherArray {

    _otherArray = otherArray;
    [self.tableView reloadData];
}

@end
